package scyDirection

import (
	"github.com/gin-gonic/gin"
	"likeadmin/clog"
	"likeadmin/dbc"
	"likeadmin/model"
	"likeadmin/sqlop"
	"likeadmin/webu"
	"time"
)

func CreateScyDirection(c *gin.Context) {
	scyDirection := &model.ScyDirection{}
	c.ShouldBind(scyDirection)
	scyDirection.CreateTime = time.Now().Unix()
	clog.Info("scyDirection,CreateScyDirection,scyDirection=", scyDirection)
	err := dbc.DB.Create(scyDirection).Error
	webu.GinResult("CreateScyDirection Error:", c, err)
}

func UpdateScyDirection(c *gin.Context) {
	scyDirection := &model.ScyDirection{}
	c.ShouldBind(scyDirection)
	clog.Info("scyDirection,UpdateScyDirection,scyDirection=", scyDirection)
	err := sqlop.ExecFourP("update scy_direction set scy_direction_name=?,scy_direction_introduction=?,update_time=? where id=?", scyDirection.ScyDirectionName, scyDirection.ScyDirectionIntroduction, time.Now().Unix(), scyDirection.Id)
	webu.GinResult("UpdateScyDirection Error:", c, err)

}

func DeleteScyDirection(c *gin.Context) {
	scyDirection := &model.ScyDirection{}
	c.ShouldBind(scyDirection)
	clog.Info("scyDirection,DeleteScyDirection,scyDirection=", scyDirection)
	err := sqlop.ExecTwoP("update scy_direction set is_deleted=1,delete_time=? where id=?", time.Now().Unix(), scyDirection.Id)
	webu.GinResult("DeleteScyDirection Error:", c, err)
}
